<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>新建项目</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" type="text/css" href="../../css/sm.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/normal.css" />
    <link rel="stylesheet" type="text/css" href="../../css/creatProject.css" />
    <link rel="stylesheet" type="text/css" href="../../iconfont/iconfont.css" />
</head>

<body>
    <div class="page allWarp">
        <div class="content">
            <div class="creatBox">
            	<ul>
            		<li>
            			<span class="width20">项目名称</span>
            			<span class="width80">
            				<input type="text" placeholder="请填写项目名称" class="width100 textRight pright10" v-model="projectName">
            			</span>
            		</li>
            		<li>
            			<span class="width20">客户名称</span>
            			<span class="width80">
            				<input type="text" placeholder="请填写客户名称" class="width100 textRight pright10" v-model="customerName">
            			</span>
            		</li>
            		<li>
            			<span class="width20">手机号码</span>
            			<span class="width80">
            				<input type="tel" placeholder="请填写手机号码" class="width100 textRight pright10" v-model="customerPhone">
            			</span>
            		</li>
            		<li>
            			<span class="width20">客户地址</span>
            			<span class="width80">
            				<input type="text" placeholder="请填写客户地址" class="width100 textRight pright10" v-model="customerAddress">
            			</span>
            		</li>
                    <li onclick="moveTo('saler')">
                        <span class="width20">销售人员</span>
                        <span class="width80 col999" style="display: flex;align-items: center; justify-content: flex-end;">
                            <span v-if="!salerName">选择销售人员</span>
                            <span v-text="salerName" v-if="salerName"></span>
                            <i class="iconfont icon-arrow-right right10"></i>
                        </span>
                    </li>
            	</ul>
            </div>
            <div class="saveProject" onclick="moveNext()">保存</div>
        </div>
    </div>
    <script type="text/javascript" src="../../js/zepto.js"></script>
    <script type="text/javascript" src="../../js/sm.min.js"></script>
    <script type="text/javascript" src="../../js/vue.min.js"></script>
    <script type="text/javascript" src="../../js/ajax.js"></script>
    <script type="text/javascript" src="../../js/back.js"></script>
    <script type="text/javascript">
        var salerName = GetQueryString("salerName");
        var salerUid = GetQueryString("salerUid");
        var role = GetQueryString("role");
        var phone = GetQueryString("phone");
        var creatProject_data = JSON.parse(sessionStorage.getItem('creatProject_data'));
        var keyN = JSON.parse(getCookie("user_data_two"));
        var createUid;
        var customerPhone;
        if (keyN != null) {
            createUid = keyN.userId;
        }
        console.log(creatProject_data)
        // sessionStorage.removeItem('creatProject_data');
        var demo = new Vue({
            el: '.allWarp',
            data: {
                projectName: creatProject_data ==null ? '' : creatProject_data.projectName,
                customerName: creatProject_data ==null ? '' : creatProject_data.customerName,
                customerPhone: creatProject_data ==null ? '' : creatProject_data.customerPhone,
                customerAddress: creatProject_data ==null ? '' : creatProject_data.customerAddress,
                salerName:'',
                salerUid:'',
                phone:'',
            },
        })
        demo.salerUid = salerUid;
        demo.salerName = salerName;
        demo.phone = phone;
        // 保存并跳转下个界面添加节点
        function moveNext(){
            if (!demo.projectName) {
                $.toast('请填写项目名称');
                return false;
            }
            if (!demo.customerName) {
                $.toast('请填写客户名称');
                return false;
            }
            if (!demo.customerPhone) {
                $.toast('请填写手机号码');
                return false;
            }
            if (!demo.customerAddress) {
                $.toast('请填写客户地址');
                return false;
            }
            if (!demo.salerName) {
                $.toast('请选择销售');
                return false;
            }
            var a ={
                "project":{
                    "projectName":demo.projectName,
                    "customerName":demo.customerName,
                    "customerPhone":demo.customerPhone,
                    "customerAddress":demo.customerAddress,
                    "salerName":demo.salerName,
                    "salerUid":demo.salerUid,
                    "phone":demo.phone,
                    "createUid":createUid
                }
            }
            var params = {};
            params.body = JSON.stringify(a);
            kfAjaxGet.createProject(params, function(json) {
                if (json.code == 200) {
                    var projectCode = json.data;
                    window.location = 'creatProject2.html?projectCode='+projectCode+'&role='+role;
                    re
                } else if (checkcode(json.code)) {

                } else {
                    $.toast(json.message);
                }
            })
        }
        //跳转
        function moveTo(val){
            var data = {};
            data.projectName = demo.projectName;
            data.customerName = demo.customerName;
            data.customerPhone = demo.customerPhone;
            data.customerAddress = demo.customerAddress;
            console.log(data)
            sessionStorage.setItem('creatProject_data', JSON.stringify(data))
            if(val = "saler"){
                window.location = "chooseSaler.html?isNewProject=true"+'&userType=2'+'&role='+role;
            }
        }

        $(function(){
            $('#gohome').on('click',function(){
                window.location = 'myProject.html?role='+role;
            })
        })
    </script>
</body>
</html>